<template>
	<view>
		<view v-if="loading">
			<loading></loading>
		</view>
		<view v-else class="container">
			<view class="course-body">
				<view class="course-view"  v-for="(item,index) in list" :index="index" :key="index" @click="clickItem">
					<view class="imgView">
						<image :src="item.courseUrl" mode="widthFix"></image>
					</view>
					<view class="textView">
						<text>{{item.courseName}}</text>
						<text> {{item.endTime}}</text>
					</view>
				</view>
			</view>
			<view class="load-more">
				<uni-icons v-if="loadShow" type="spinner-cycle" size="30"></uni-icons>
				<text  v-if="botShow">已经到底了</text>
			</view>
			<show-modal></show-modal>
		</view>
	</view>
</template>

<script>
	import { getCourseRecordPage } from '@/api/exam/activity'
	import {parseTime } from '@/utils/ruoyi'
	import loading from '@/components/loading/loading'
	export default {
		data() {
			return {
			pageForm:{
				pageNo:1,
				pageSize:10
				
			}	,
			workList:[
				
			],
			list:[],
			loadShow:false,
			botShow:false,
			loading:true
			}
		},
		created(){
			this.getList()
		},
		onReachBottom(){
			if(!this.botShow){
				this.loadShow = true
				this.pageForm.pageNo ++ ;
				this.getList()
			}
			
		},
		methods: {
			getList(){
				this.pageForm.studentId=uni.getStorageSync('studentId')
				getCourseRecordPage(this.pageForm).then(res =>{
					//this.list = res.data.list
					if( res.data.list.length > 0){
						for (let i = 0; i <  res.data.list.length; i++) {
							 res.data.list[i].endTime = parseTime( res.data.list[i].endTime,'{y}-{m}-{d} {h}:{i}:{s}')
						}
						this.list.push(...res.data.list)
						this.loadShow = false
					}else{
						this.loadShow = false
						this.botShow = true
					}
					this.loading = false
				})
			},
			clickItem(){
				uni.navigateBack()
			}
			
		}
	}
</script>

<style lang="scss">
	.container{
		width: calc(100vw - 60rpx);
		margin: 0 auto;
		min-height: 650px;
	}
	.course-body{
		border-radius: 20rpx;
		.course-view{
			background-color: #fff;
			margin-top: 20rpx;
			border-radius: 10rpx;
			box-shadow: 0px 2px 34px 5px rgba(156,193,220,0.25);
			overflow: hidden;
			display: flex;
			padding: 10px 0 10px 0;
			.imgView{
				width: 120rpx;
				height: 120rpx;
				height: auto;
				margin: 20rpx;
				overflow: hidden;
				
			}
			.textView{
				font-family: Inter-Regular, Inter;
				font-weight: 400;
				line-height: 60rpx;
				padding-left: 20rpx;
				text{
					display: block;
				}
			}
		}
	}
	.load-more{
		display: block;
		padding: 20px;
		margin: 0 auto;
		text-align: center;
	}
</style>